package com.company.statis.schedule;

import com.company.statis.service.StatisticsDailyService;
import com.company.utils.DateUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
public class ScheduledTask {

    @Resource
    private StatisticsDailyService dailyService;

    //凌晨一点统计网站数据
    @Scheduled(cron = "0 0 1 * * ?")
    public void task() {
        dailyService.saveStatistics(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }

}
